<?php
/**
 * --------------------------------------------------------------
 * 前台基础控制器
 * --------------------------------------------------------------
 * Light Year Doc
 * @author yinq<3331653644@qq.com>
 * --------------------------------------------------------------
 */
namespace app\common\controller;

use app\admin\model\Navigation as NavigationModel;
use app\admin\model\Menu as MenuModel;

class HomeBase extends Base
{
    /**
     * 初始化
     */
    protected function initialize()
    {
        parent::initialize();

        // 网站导航
        $nav_menu_list = cache('nav_menu_list');
        if (!$nav_menu_list) {
            $navInfo       = NavigationModel::where(['en_title' => 'index_top_nav', 'status' => 1])->find();
            $menuList      = MenuModel::queryOneOrList(['status' => 1], 'id,pid,type,title,en_title,column_id,url,page_id,target', 'list', 'id asc,sort asc');
            $nav_menu_list = get_nav_menu($menuList);
            $nav_menu_list = list_to_tree_two($nav_menu_list);
            // 非开发模式，缓存导航信息
            if (config('app.site_setting.develop_mode') == 0) {
                cache('nav_menu_list', $nav_menu_list);
            }
        }

        $this->assign([
            'nav_menu_list' => $nav_menu_list,
            'site_name'     => config('app.site_setting.web_site_slogan')
        ]);
    }
}